package com.boolib.shopadmin.config.shiro.filter;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.authc.LogoutFilter;
import org.springframework.http.HttpRequest;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

@Slf4j
public class SystemLogoutFilter  extends LogoutFilter {

    @Override
    protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {



        Subject subject = getSubject(request,response);
        String redirectUrl = getRedirectUrl(request, response, subject);
        subject.logout();
        issueRedirect(request,response, redirectUrl);
        return false;
    }

    @Override
    protected void issueRedirect(ServletRequest request, ServletResponse response, String redirectUrl) throws Exception {
        super.issueRedirect(request, response, redirectUrl);
    }
}
